package com.usmarter.server.services;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.usmarter.model.AnswerEntity;
import com.usmarter.server.db.MyDB;

@Service
@Path("/answer")
public class AnswerRestService {
	@Autowired
	private MyDB myDB;

	@GET
	@Path("/{id}")
	@Produces(MediaType.APPLICATION_JSON)
	public String createAnswer(@PathParam("qid") long qid) {
		AnswerEntity entity = new AnswerEntity();
		entity.setQuestionID(qid);
		long id = myDB.createAnswer(entity);
		return "Added answer #"+id;
	}
//
//	@GET
//	@Path("/{id}")
//	@Produces(MediaType.APPLICATION_JSON)
//	public String getQuestion(@PathParam("id") long id) {
//		return myDB.getAnswer(id).toString();
//	}
}
